import enum


class BaseEnum(enum.Enum):
    """
    抽象基类，强制__str__方法，并且定义好to_frontend_dict方法
    """

    @classmethod
    def to_frontend_dict(cls):
        """
        此方法用来得到所有的int->前端
        """
        return cls._frontend_dict.value

    @classmethod
    def to_frontend_list(cls):
        """
        此方法用来得到所有的int->前端
        """
        temp_list = []
        for key, value in cls.to_frontend_dict().items():
            temp_list.append({
                "id": key,
                "value": value
            })
        return temp_list

    @classmethod
    def to_frontend_id_list(cls):
        """
        此方法用来得到所有的id
        """
        temp_list = []
        for key, value in cls.to_frontend_dict().items():
            temp_list.append(key)
        return temp_list

    @classmethod
    def to_frontend_desc(cls, value):
        """
        此方法用来得到所有的int->前端
        """
        return cls._frontend_dict.value[value]
